package com.yang.action;

import com.yang.entity.Orderdetail;
import com.yang.service.OrderdetailService;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/OrderdetailQueryById")
public class OrderdetailQueryByIdAction extends HttpServlet {
    OrderdetailService orderdetailService = new OrderdetailService();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        Orderdetail obj = orderdetailService.queryOrderdetailById(Integer.parseInt(id));
        resp.setContentType("text/json;charset=utf-8");
        PrintWriter out = resp.getWriter();
        Gson g = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
        out.write(g.toJson(obj));
        out.flush();
        out.close();
    }
}

